-include_lib("eunit/include/eunit.hrl").

-define(BENCHMARK, false).

-define(KEY_FOR_LAST_RECORD, 1).

-define(DEFAULT_TEST_LENGTH, 50).

-define(TRESHOLD, 200).

-define(DEVICE_SOURCE, mock). %%android

-export_type([device/0, test/0, state/0, message/0, test_id/0, device_id/0, worker/0, state_id/0]).

-record(deviceDescriptor,
{
  id :: integer(),
  description = "" :: string(),
  driver :: pid()

}).

-record(key_id_dts,
{
  key = ?KEY_FOR_LAST_RECORD,
  value = 0
}).

% 2, 8, 12, 32, 2, 8
-record(message,
{
  fh,
  deviceCode,
  operation,
  data,
  fk,
  crc
}).

-record(testCase,
{
  id = -1 :: integer(),
  deviceId :: integer(),
  dataField = [] :: [binary()],
  dataFieldLen = 0 :: integer(),
  desiredAnswer = [] :: [byte()],
  description = "default description" :: string()
}).



-record(stateRecord,
{
  id = -1 :: integer(),
  testId = -1 :: integer(),
  deviceId = -1 :: integer(),
  answer = [] :: [byte()],
  completed = false :: boolean(),
  sends = 0 :: integer(),
  fails = 0 :: integer(),
  unexpected_answer = false :: boolean()
}).

-record(testingState,
{
  devicesCount = 0 :: integer(),
  devicesFinished = 0 :: integer(),
  reported = false :: boolean(),
  start,
  finish,
  message = "tests are run: ~w ms~n" :: string()
}).

-type device() :: #deviceDescriptor{}.
-type test() :: #testCase{}.
-type state() :: #stateRecord{}.
-type message() :: #message{}.

-type test_id() :: pos_integer().
-type device_id() :: pos_integer().
-type state_id() :: pos_integer().
-type worker() :: pid().